//Alisa Burdeyny

import java.awt.*; 
import java.applet.Applet; 
import java.awt.geom.*;

/*****
 *Draws the main menu and instructions panels
 *****/
public class MainMenuPanel extends Applet{

	boolean inst = false;
	boolean play = false;
	
	//sets size to 800x400
	public void init() 
	{ 
		resize(800, 400);
	}
	
	//paints the starting and instruction panels
	public void paint(Graphics g) 
	{ 
		Graphics2D g2 = (Graphics2D) g; 
		g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
		
		//draws the background
		drawSky(g2);
		drawGround(g2);
		
		//if the user hasn't clicked the instructions or start buttons, draw main menu
		if(inst == false)
		{
			drawStartButton(g2);
			drawInstructionsButton(g2);
			drawPrettyTitle(g2);
		}
		//if the user clicks on the instructions button, draw the instructions panel
		else
		{
			drawInstructionPanel(g2);
		}
	}
	
	public void drawSky(Graphics2D g)
	{
		Rectangle2D.Double sky = new Rectangle2D.Double(); 
		sky.setFrame(0,0,800,400); 
		Color paleBlue = new Color(135, 206, 235); 
		g.setColor(paleBlue); 
		g.fill(sky); 
	}
	
	public void drawGround(Graphics2D g)
	{
		GeneralPath ground = new GeneralPath();
		ground.moveTo(0f, 280f);
		ground.quadTo(400f, 200f, 800f, 280f);
		ground.lineTo(800f, 400f);
		ground.lineTo(0f, 400f);
		ground.closePath();
		Color paleGreen = new Color(204, 255, 153); 
		g.setColor(paleGreen); 
		g.fill(ground); 
	}
	
	public void drawStartButton(Graphics2D g)
	{
		Color startBlue = new Color(16, 78, 139, 100);
		
		Rectangle2D.Double startBox = new Rectangle2D.Double();
		startBox.setFrame(265, 150, 270, 100);
		g.setColor(startBlue);
		g.fill(startBox);
		g.setColor(Color.yellow);
		g.draw(startBox);
		
		g.setFont(new Font("Times New Roman", Font.BOLD, 60));
		g.drawString("Start", 330f, 225f);
	}
	
	public void drawInstructionsButton(Graphics2D g)
	{
		Color startBlue = new Color(16, 78, 139, 100);
		
		Rectangle2D.Double instBox = new Rectangle2D.Double();
		instBox.setFrame(265, 275, 270, 100);
		g.setColor(startBlue);
		g.fill(instBox);
		g.setColor(Color.YELLOW);
		g.draw(instBox);
		
		g.setFont(new Font("Times New Roman", Font.BOLD, 50));
		g.drawString("Instructions", 270f, 345f);
	}
	
	public void drawPrettyTitle(Graphics2D g)
	{
		Color frisbeeColor1 = new Color(153, 204, 255);      //new color for lighted part of frisbee
		Color frisbeeColor2 = new Color(0, 0, 205);        //new color for shaded part of frisbee
		
		//draws the word STREAK
		g.setColor(Color.YELLOW);
		g.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 90));
		g.drawString("STREAK", 360f, 105f);
		
		g.setPaint(new GradientPaint(510f, 30f, frisbeeColor1, 600f, 200f, frisbeeColor2));
		Ellipse2D.Double flyingFrisbee = new Ellipse2D.Double();
		flyingFrisbee.setFrame(510.0, 50.0, 40.0, 80.0);
		g.rotate(-150, 530, 90);
		g.fill(flyingFrisbee);
		g.setColor(frisbeeColor2);
		g.draw(flyingFrisbee);
		g.rotate(150, 530, 90);
		
		//draws the streaks of the frisbee
		GeneralPath streak1 = new GeneralPath();
		GeneralPath streak2 = new GeneralPath();
		GeneralPath streak3 = new GeneralPath();
		GeneralPath streak4 = new GeneralPath();
		GeneralPath streak5 = new GeneralPath();
		
		streak1.moveTo(500f, 100f);
		streak1.quadTo(325f, 105f, 240f, 60f);
		
		streak2.moveTo(505f, 90f);
		streak2.quadTo(325f, 95f, 245f, 55f);

		streak3.moveTo(510f, 80f);
		streak3.quadTo(325f, 85f, 250f, 50f);

		streak4.moveTo(520f, 70f);
		streak4.quadTo(325f, 75f, 260f, 45f);
		
		streak5.moveTo(498f, 110f);
		streak5.quadTo(325f, 115f, 238f, 65f);
		
		g.draw(streak1);
		g.draw(streak2);
		g.draw(streak3);
		g.draw(streak4);
		g.draw(streak5);
		
		//draws the word BLUE
		g.setColor(Color.YELLOW);
		g.setFont(new Font("Times New Roman", Font.BOLD+Font.ITALIC, 90));
		g.drawString("BLUE", 90f, 105f);
	}
	
	public void drawInstructionPanel(Graphics2D g)
	{
		Color instructionsBlue = new Color(16, 78, 139, 100);
		
		//draws the "back" button
		Rectangle2D.Double instPanel = new Rectangle2D.Double();
		instPanel.setFrame(50, 85, 700, 250);
		g.setColor(instructionsBlue);
		g.fill(instPanel);
		g.setColor(Color.yellow);
		g.draw(instPanel);
		
		Rectangle2D.Double backButton = new Rectangle2D.Double();
		backButton.setFrame(350, 345, 100, 50);
		g.setColor(instructionsBlue);
		g.fill(backButton);
		g.setColor(Color.yellow);
		g.draw(backButton);
		
		//writes the instructions in the box
		g.setFont(new Font("Times New Roman", Font.BOLD, 85));
		g.drawString("Instructions", 175f, 75f);
		
		g.setFont(new Font("Times New Roman", Font.BOLD, 35));
		g.drawString("Back", 362f, 383f);
		
		g.setFont(new Font("Times New Roman", Font.PLAIN, 20));
		g.drawString("Use up arrow to move forward, left arrow to turn left, and right arrow to turn right", 55f, 120f);
		
		g.drawString("Use mouse to aim, click and drag to determine angle of throw, release to release", 55f, 160f);
		
		g.drawString("Pinkish: you, the user", 55f, 200f);
		g.drawString("Red: the home team, your team", 55f, 220f);
		g.drawString("Blue: the away team, your opponents (don't let them get the frisbee)", 55f, 240f);
		g.drawString("Yellow: the person holding the frisbee (overrides their team color until they throw)", 55f, 260f);
		
		g.setFont(new Font("Times New Roman", Font.BOLD, 20));
		g.drawString("When not holding frisbee:", 55f, 100f);
		g.drawString("When holding frisbee:", 55f, 140f);
		g.drawString("What the colors mean:", 55f, 180f);
	}
	
	//makes the program switch back and forth between instructions window and main menu
	public void setInst(boolean instructions)
	{
		inst = instructions;
		repaint();
	}
}